home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 20 / 020.d81 / t.pps #45 < prev    next >
Text File  |  2022-08-26  |  2KB  |  117 lines

  1. ======================================
  2.     PEEKs, POKEs, & SYSes, part 45
  3.  
  4.    by Jim Weiler and Reggie Beavers
  5. ======================================
  6.           ---------------
  7.           HOW PITCH WORKS
  8.           ---------------
  9.  
  10.   Whenever SID finds a "wave on"
  11.  
  12. value in one of his waveform
  13.  
  14. registers, he makes noise at a
  15.  
  16. specific frequency.  That frequency
  17.  
  18. is determined by the values in his
  19.  
  20. pitch registers.  (S+0 and S+1 are
  21.  
  22. the pitch registers for voice 1.)
  23.  
  24.   S+0 holds the low byte of pitch and
  25.  
  26. S+1 contains the high byte.  SID
  27.  
  28. doesn't care whether the value in the
  29.  
  30. pitch registers is stable or
  31.  
  32. fluctuating.  He will always try to
  33.  
  34. play the pitch described therein.
  35.  
  36. That makes it possible to step from
  37.  
  38. one note to another, or to slide
  39.  
  40. gently through the scales.  It all
  41.  
  42. depends on how smoothly you change
  43.  
  44. the values in the pitch registers.
  45.  
  46.  
  47.   Here, again, is the BASIC
  48.  
  49. code to make SID play a C-sharp.
  50.  
  51. 1 S = 54272
  52. 2 POKE S+0,12:POKE S+1,71  (c-sharp)
  53. 3 POKE S+24,15             (volume)
  54. 4 POKE S+5,9:POKE S+6,0    (envelope)
  55. 5 POKE S+4,33              (play it)
  56. 6 FOR A=1 TO 200: NEXT     (delay it)
  57. 7 POKE S+4,32              (stop it)
  58.  
  59.   Line 2 is what we're interested in
  60.  
  61. this time.  How does POKE S+0,12:
  62.  
  63. POKE S+1,71 translate into C-sharp?
  64.  
  65. Well... um... it just DOES.  When SID
  66.  
  67. finds pitch registers containing the
  68.  
  69. value 18188 (that's 71*256 + 12) it
  70.  
  71. puts out a tone with the same pitch
  72.  
  73. as C-SHARP.  It's completely
  74.  
  75. arbitrary, but it's also completely
  76.  
  77. true.  What about the rest of the
  78.  
  79. notes?  Look in the last PEEKs,
  80.  
  81. POKEs, and SYSes article for the
  82.  
  83. details.
  84.  
  85.                ------
  86.                SLIDER
  87.                ------
  88.  
  89.   You aren't limited to playing
  90.  
  91. single notes, one after the other.
  92.  
  93. As I implied before, you can change
  94.  
  95. pitch on the fly just by poking new
  96.  
  97. values into the pitch registers.
  98.  
  99. Let's say we wanted that C-sharp tone
  100.  
  101. we generated above to slide down an
  102.  
  103. octave to the next lower C-sharp,
  104.  
  105. like a slide whistle.  All we have to
  106.  
  107. do is change our delay loop to make
  108.  
  109. it poke new pitches into the pitch
  110.  
  111. registers:
  112.  
  113. 6 FOR A=71 TO 35 STEP-.15:POKE S+1,A:
  114.   NEXT: POKE S+0,134
  115.  
  116.  ====<continued in next article>====
  117.